<template>
  <div>
    <div ref="echarts" style="width: 600px; height: 400px;"></div>
  </div>
</template>

<script>
import * as echarts from 'echarts'
export default {
  name: 'EChartsComponent',
  data () {
    return {
      myChart: undefined
    }
  },
  mounted () {
    this.myChart = echarts.init(this.$refs.echarts)
    const option = {
      title: {
        text: '饼图',
      },
      tooltip: {
        trigger: 'item'
      },
      legend: {
        orient: 'horizontal',
      },
      series: [
        {
          name: 'Access From',
          type: 'pie',
          radius: '50%',
          data: [
            { value: 1048, name: 'Search Engine' },
            { value: 735, name: 'Direct' },
            { value: 580, name: 'Email' },
            { value: 484, name: 'Union Ads' },
            { value: 300, name: 'Video Ads' }
          ],
          // 文本样式
          textStyle: {
            color: 'rgba(255,0, 0, 0.3)'
          },
          // 引导线样式,文本和图的连线
          labelLine: {
            lineStyle: {
              color: 'rgba(0, 255, 0, 0.3)'
            }
          },
          // 高亮
          emphasis: {
            // 扇形样式
            itemStyle: {
              shadowBlur: 10,
              shadowOffsetX: 0,
              shadowColor: 'rgba(0, 0, 0, 0.5)'
            }
          }
        }
      ]
    }
    this.myChart.setOption(option)
  }
}
</script>
<style lang="scss" scoped></style>
